GetAxisByIndex
Gets information from an axis.
Syntax
KsError GetAxisByIndex(
int Index,
SlaveStatus* Details,
int* Resolution,
DWORD* InputVariables,
DWORD* OutputVariables
);
Parameters
Index: the index of an axis. Indexes are zero based. Aliases affect this parameter.
Details: pointer to the SlaveStatus structure that receives the axis information.
Resolution: the encoder resolution of the axis. The resolution depends on the Resolution object in the ESI database. If the Resolution object is selected, the resolution will be the value stored in the object. If Resolution object is not selected, the Default Resolution in the ESI database will be applied.
InputVariables: the input variables available in the PDO data. The table below shows the bit masks of InputVariables.
OutputVariables: the output variables available in the PDO data. The table below shows the bit masks of OutputVariables.
Bit mask for InputVariables
Hexadecimal bit mask | Variable |
---|---|
0x1 | VAR_STATUS_WORD |
0x2 | VAR_ACTUAL_POSITION |
0x4 | VAR_SECOND_ENCODER |
0x8 | VAR_ACTUAL_VELOCITY |
0x10 | VAR_ACTUAL_TORQUE |
0x20 | VAR_TOUCH_PROBE_STATUS |
0x40 | VAR_MOP_DISPLAY |
0x80 | VAR_AXIS_INPUTS |
Bit mask for OutputVariables
Hexadecimal bit mask | Variable |
---|---|
0x1 | VAR_CONTROL_WORD |
0x2 | VAR_TARGET_POSITION |
0x4 | VAR_TARGET_VELOCITY |
0x8 | VAR_TARGET_TORQUE |
0x10 | VAR_TORQUE_OFFSET |
0x20 | VAR_TOUCH_PROBE_CONTROL |
0x40 | VAR_MOP |
0x80 | VAR_AXIS_OUTPUTS |
Return value
If the function succeeds, it returns errNoError
, otherwise an error code. For more information about the error code, see the KsError list.
Remarks
Gets the axis and its encoder resolution details. Used after the KINGSTAR Subsystem is started.
Usable EtherCAT states
ecatOP
Example
SlaveStatus slaveStatus = { 0 };
int resolution = 0;
DWORD InputVar = 0, OutputVar = 0;
nRet = GetAxisByIndex(0, &slaveStatus, &resolution, &InputVar, &OutputVar);
if (nRet == errNoError)
{
// Check the slave information in the SlaveStatus structure.
RtPrintf("Axis 0 %s: Vendor 0x%x, Product 0x%x, Revision 0x%x, Serial 0x%x\n",
slaveStatus.Name, slaveStatus.VendorId, slaveStatus.ProductCode,
slaveStatus.RevisionNumber, slaveStatus.SerialNumber);
RtPrintf("Address: Auto %d, Fixed %d, Alias %d\n",
slaveStatus.SlaveId, slaveStatus.PhysAddress, slaveStatus.AliasAddress);
RtPrintf("PDO: Input len %d, Output len %d, Index offset 0x%x\n",
slaveStatus.InputLength, slaveStatus.OutputLength, slaveStatus.VariableIndexOffset);
RtPrintf("State %d, Cycle time %d\n", slaveStatus.State, slaveStatus.CycleTime);
// Use defined bit mask to check if desired variables are in the PDO data.
if ((InputVar & VAR_MOP_DISPLAY) == VAR_MOP_DISPLAY) {
BYTE mopDisplay = 0;
nRet = ReadAxisMopDisplay(0, &mopDisplay);
if (mopDisplay != 8 && (OutputVar & VAR_MOP) == VAR_MOP) {
nRet = WriteAxisMop(0, 8);
}
}
}
Requirements
RT | Win32 | |
---|---|---|
Minimum supported version | 4.0 | 4.0 |
Header | ksapi.h | ksapi.h |
Library | KsApi_Rtss.lib | KsApi.lib |
See also